{extend name="../app/index/view/layout/main.html" /}
//网站标题
{block name="title"}<title>设置 - {$meta.appname}</title>{/block}

//css资源
{block name="link"}
<!-- 第三方库css -->
<link rel="stylesheet" href="__STATIC__/lib/layui/css/layui.css">
<link rel="stylesheet" href="__STATIC__/lib/swiper/css/swiper.css">

<!-- 自定义css -->
<link rel="stylesheet" href="__INDEX_STATIC__/css/common.css">
<link rel="stylesheet" href="__INDEX_STATIC__/css/app.css">
<style>
  .footer{
    position: fixed;
    bottom: 0;
    width: 100%;
  }
</style>
{/block}

//js资源
{block name="script"}
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__INDEX_STATIC__/js/config.js"></script>
<script>
    'use strict';
    layui.use(['layer', 'jquery', 'nav','form'], function(){
        let layer = layui.layer
            ,$ = layui.jquery
            ,form = layui.form
            ,flag = true;


        //监听提交
        form.on('submit(formPassword)', function(data){
            if (!flag) return false;

            flag = false;

            $.ajax({
                url : '{:url("savePassword")}',
                type: 'POST',
                data: data.field,
                success: function(d){
                    layer.msg(d.msg,function(){
                        if (d.code === 0){
                            window.location.reload();
                        }
                        flag = true;
                    })
                }
            });

            return false;
        });


    });
</script>
{/block}

//body
{block name="body"}
<!-- body -->
<section class="body top-25">
  <div class="layui-container">
    <div class="layui-row layui-col-space20">
      <div class="layui-col-md3">
        {include file="user/nav" curr="setPassword" /}
      </div>
      <div class="layui-col-md9">
        <div class=" block">
          <div class="block-header flex-def flex-zBetween">
            <h2>修改密码</h2>
          </div>
          <div class="setting">
            <form class="layui-form" action="">
              <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                  <input type="text" value="{$user.username}" disabled class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">原密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="ori_password" required lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="new_password" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">最少6位字符</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="re_password" required lay-verify="required" placeholder="请确认新密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">请确认新密码</div>
              </div>


              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="formPassword">立即提交</button>
                  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>

    </div>

  </div>
</section>
{/block}